package com.houseman.workFlow.processer.impl;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.houseman.workFlow.bean.WorkFlowGraph;
import com.houseman.workFlow.processer.Processer;
import com.houseman.workFlow.service.GraphService;
import com.houseman.workFlow.service.impl.GraphServiceImpl;
import com.houseman.workFlow.utils.GraphToJson;

/**
 * 导入已有流程图
 */
public class ImportProcesser extends Processer{

	//service
	GraphService service = new GraphServiceImpl();
	
	@Override
	public void proccess(HttpServletRequest request, HttpServletResponse response) {
		String graphId = request.getParameter("graphId");
		
		try {
			WorkFlowGraph graph = service.queryWorkFlowGraph(new Integer(graphId));
			
			GraphToJson util = new GraphToJson();
			String json = util.toJson(graph);
			
			//数据处理后返回处理结果提示
			response.setCharacterEncoding("UTF-8");
			response.setContentType("application/json");
			
			PrintWriter out = response.getWriter();
			out.print(json);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
